Skip to content

Support multi-schema introspection in common.ai SQLToolset#68103

Merged
kaxil merged 1 commit into
apache:mainfrom
astronomer:sqltoolset-multi-schema-introspection
Jun 6, 2026
Merged

Support multi-schema introspection in common.ai SQLToolset#68103
kaxil merged 1 commit into
apache:mainfrom
astronomer:sqltoolset-multi-schema-introspection

Conversation

@kaxil

@kaxil kaxil commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

The common.ai SQLToolset metadata tools (list_tables, get_schema) operated against a single schema, so an agent over a multi-schema warehouse (common on Snowflake) could not discover tables across schemas. With no schema set and schema-qualified tables, list_tables introspected a literal "None" schema (SHOW TABLES IN SCHEMA "DB"."None") and failed.

allowed_tables entries may now be schema-qualified ("SCHEMA.TABLE"). list_tables introspects each referenced schema and returns the matching tables fully qualified, and get_schema routes each qualified name to its own schema.

How it works

  • Qualified entries are grouped by their schema; list_tables queries each schema and emits SCHEMA.TABLE names, filtered to the allow-list. get_schema("SCHEMA.TABLE") splits the identifier and passes the schema to the hook.
  • Unqualified entries and the allow-all case keep the previous single-schema behaviour using the default schema, so existing setups are unchanged.
  • Table-name matching is case-insensitive, because databases reflect identifiers in their own case (Snowflake reflects unquoted names lowercased) and a byte-exact match against uppercase entries would otherwise return nothing. The filter is a visibility hint, not access control, so this is safe.
  • Results are de-duplicated by (schema, table) so a table reachable both qualified and via the default schema is listed once.

Usage

SQLToolset(
    db_conn_id="snowflake_hq",
    allowed_tables=["MODEL_ASTRO.DEPLOYMENT_IMAGE_DETAILS", "MODEL_CRM.SF_ASTRO_ORGS"],
)

Gotchas

  • The schema name passed to the database must match its own identifier casing (uppercase on Snowflake, lowercase on Postgres); case-insensitive matching covers the allow-list filter against reflected names, not the schema lookup itself.
  • Cross-database tables are out of scope: use a separate toolset whose connection points at that database.

SQLToolset's metadata tools (list_tables, get_schema) operated against a single
schema, so an agent over a multi-schema warehouse (common on Snowflake) could
not discover tables across schemas. With no schema set and schema-qualified
tables, list_tables introspected a literal "None" schema
(SHOW TABLES IN SCHEMA "DB"."None") and failed outright.

allowed_tables entries may now be schema-qualified ("SCHEMA.TABLE"). list_tables
introspects each referenced schema and returns the matching tables fully
qualified, and get_schema routes each qualified name to its own schema.
Unqualified entries and the allow-all case keep the previous single-schema
behaviour using the default schema. Table-name matching is case-insensitive,
because databases reflect identifiers in their own case (Snowflake reflects
unquoted names lowercased) and a byte-exact match would silently return nothing.
Results are de-duplicated by (schema, table) so a table reachable both qualified
and via the default schema is listed once.
@kaxil kaxil force-pushed the sqltoolset-multi-schema-introspection branch from 9fecd5d to 077ef05 Compare June 5, 2026 22:35

@gopidesupavan gopidesupavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kaxil kaxil merged commit d885045 into apache:main Jun 6, 2026
94 checks passed
@kaxil kaxil deleted the sqltoolset-multi-schema-introspection branch June 6, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants